//
//  GYDTabBarViewModel.swift
//  Weibo
//
//  Created by 贵永冬 on 16/7/15.
//  Copyright © 2016年 贵永冬. All rights reserved.
//

import UIKit

class GYDTabBarViewModel: NSObject {
    weak var tabBarVC : GYDTabBarController?
    
    init(tabBarVC:GYDTabBarController) {
        self.tabBarVC = tabBarVC
        super.init()
    }
    /**
     处理按钮点击
     */
    func solvePublishType(publishType : PublishType) {
        print(publishType)
        
        if !GYDUserModel.sharedInstance.isLogin {
            let loginVC = GYDLoginViewController()
            self.tabBarVC?.presentViewController(loginVC, animated: true, completion: nil)
            return
        }
        
        if publishType == PublishType.Text {
            GYDSendWBViewController.showWithVC(self.tabBarVC!)
        }
    }
    /**
     显示发布界面
     */
    func showPublishView() -> Void {
        let publishView = GYDPublishView(frame:UIScreen.mainScreen().bounds)
        publishView.showButtons()
        publishView.publishTypeBlock = { [unowned self] (publishType : PublishType) in
            self.solvePublishType(publishType)
        }
        self.tabBarVC?.view.addSubview(publishView)
    }
}
